package com.eva.learn.other;

import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by evain on 15/8/22.
 */
public class ThreadTest {
    public static void main(String[] args) {


        ExecutorService executorService = Executors.newFixedThreadPool(2);


    }

    public static void test(){
        System.out.println(Thread.currentThread().getName());

        String name = ManagementFactory.getRuntimeMXBean().getName();
        System.out.println(name);
// get pid
        String pid = name.split("@")[0];
        String ip = getInetAddress().getHostAddress();
        System.out.println("Pid is: "+ pid);
        System.out.println(ip);
    }

    public static InetAddress getInetAddress(){

        try{
            return InetAddress.getLocalHost();
        }catch(UnknownHostException e){
            System.out.println("unknown host!");
        }
        return null;

    }
}
